<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="js/jquery-3.2.1.js"></script>
<title>用户名唯一性</title>


</head>
<script type="text/javascript">
function ajaxValidate() {
    var username=$("#username").val();
    var password=$("#password").val();
    var name=$("#name").val();
    var sex=$("#sex").val();
    var age=$("#age").val();
    var phone=$("#phone").val();
    $.ajax({
        type:"POST",
        url:"${pageContext.request.contextPath}/doCheckUsername",
        /**data:"username="+username, "password="+password,"name="+name,"sex="+sex,"age="+age,"phone="+phone ,**/
        data:{"username":username,"password":password,"name":name,"sex":sex,"age":age,"phone":phone},
        dataType:"json",
        success:function(data){
            if ("no" == data.msg) {
                alert("抱歉，该用户已被注册，请更换！");
            }else if("yes" ==data.msg)
              {
            	 alert("注册成功！");
                 window.location.href="LR.jsp";
               }
            
            
        }
    });
}

</script>

<body>

		<form action="doCheckUsername">
	<!-- 	<span id="remind" color="red"></span> -->
			用户名：<input type="text" name="username" id="username" onblur="ajaxValidate()" ></br>
			密    码：<input type="password" name="password" id="password"></br>
			姓    名：<input type="text" name="name" id="name"></br>
			性    别：<input type="text" name="sex"  id="sex"></br>
			年    龄：<input type="text" name="age" id="age"></br>
			电    话：<input type="text" name="phone" id="phone"></br>
				<button onclick="ajaxValidate()" >提交</button>
			</form>


</body>

</html>